<!-- extend base layout -->
{% extends "base.html" %}
{% block content %}
	<div class="loginlist">
    	<div class="topico"><i class="icon-ico">&#xf015;</i><i class="icon-ico">&#xf013;</i></div>
        <h3 class="tit">登录<span>login to your account</span></h3>
      <ul class="listform">
        	<li class="selected"><span class="tip"></span>
            	<i class="icon-ico">&#xf007;</i>
            	<input type="text" class="form-text" placeholder="用户名" maxlength="20" id="loginCode">
          	</li>
        	<li><span class="tip"></span>
            	<i class="icon-ico">&#xf023;</i>
           	 	<input type="password" placeholder="密码" class="form-text" id="password"  maxlength="20" >
            </li>
        	<li class="botend">
                  <span id="message" style="text-align:left;float:left;color:#f60"></span>
                  <button class="btn btn-success" id="Submit"><i class="icon-ico">&#xf011;</i><span>登录</span></button>
            </li>
        </ul>
        <h4 class="endtit"><i class="icon-ico">&#xf043;</i>忘记你的密码？</h4>
        <div class="endtext">忘记密码或者是有任何问题请联系管理员<span></span></div>
    </div>

    <link rel="stylesheet" type="text/css"   href="{{ url_for('.static', filename='immanage_source/3.2.1/assets/font-awesome/css/font-awesome.min.css') }}">
    <link rel="stylesheet" type="text/css"   href="{{ url_for('.static', filename='immanage_source/css/login.css') }}">


<script type="text/javascript">
$(function() {
	if(window != window.top){
		window.top.location.reload();
	}

	$(".listform li:first>input").focus();
	$(".listform li:first").children("input").trigger("focus");
	$(".listform li input").focus(function(){
		$(this).parents("li").siblings("li").children("input").css({"border-color":"#d8d6d6"});
		$(this).css({"border-color":"#F67919"});
		$(this).parents("li").siblings("li").removeClass("selected");
		$(this).parents("li").addClass("selected");
	});
	function tips(thistip, vels){
			thistip.empty().text(vels).css({"left":"255", "top":"18px"}).show().animate({"left":"265", "top":"18px"});

	};

	function UserCheck()
	{
		re=/^[A-Za-z0-9]+$/;
		 if($("#loginCode").val()=="")
		{
			tips($("#loginCode").parents("li").children(".tip"),"用户名不能为空");
			return false;

		}
		return true;
	};


	function PassCheck()		//left中用户登录的密码验证
	{
		var pass=$("#password").val();
		if(pass.length==0)
		{
			tips($("#password").parents("li").children(".tip"),"密码不能为空");
			//alert("密码不能为空！！！");
			pass=='';			//重新输入时把原来的内容清空
			//$("#password").focus();//要求重新输入
			return false;
		}

		return true;

	};

	function getSysFlag(){
		var sysFlag="PC";

		var ua = navigator.userAgent.split(";");
		if(ua.join("-").indexOf("Mobile")!=-1){
			sysFlag = "MOB"
		}
		return sysFlag;
	}

	$("#Submit").click(function(){
		$(".tip").hide();
		var uc = UserCheck();
		var pc = PassCheck();
		//alert(uc+"::"+pc)
		if(uc&&pc){
			var param = "loginCode="+$('#loginCode').val()+"&password="+$('#password').val()+"&login_sys="+getSysFlag();
			$.post('login/login', param,
	              function (data, textStatus) {
	            	if(data.message==""||data.message==null){
	            		window.location.href="login/main";
	                }else{
						$("#message").html(data.message)
	                }
	          },'json');
		}
	});

});
</script>

{% endblock %}

